<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRecordsTable extends Migration
{

    public function up()
    {
        Schema::create('records', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('currentTimes')->default(0)->comment('当前次数');
            $table->enum('type', ['donate', 'writeOff'])
                ->default('donate')->comment('转移类型donate：转赠writeOff：核销');
            $table->string('remark')->default('')->comment('备注信息');
            $table->timestamps();

            $table->foreignUuid('voucher_id')->reference('uuid')->on('vouchers')
                ->onDelete('cascade')->comment('卡券外键');
            $table->foreignId('user_id')->nullable()->comment('所属用户');
        });
    }

    public function down()
    {
        Schema::dropIfExists('records');
    }
}
